package jubao.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.whu.zj.MyApplication;
import com.whu.zj.R;

import java.util.ArrayList;
import java.util.List;

import jubao.dto.GrassrootsOpinion;
import model.Message;

/**
 * Created by Administrator on 2016/12/22.
 */
public class JuBaoViewAdapter extends BaseAdapter {

    List<GrassrootsOpinion> grassrootsOpinions=new ArrayList<GrassrootsOpinion>();

    public List<GrassrootsOpinion> getGrassrootsOpinions() {
        return grassrootsOpinions;
    }

    public void setGrassrootsOpinions(List<GrassrootsOpinion> grassrootsOpinions) {
        this.grassrootsOpinions = grassrootsOpinions;
    }

    @Override
    public int getCount() {
        return grassrootsOpinions.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(MyApplication.share(), R.layout.item_grassrootsopinion, null);


//            viewHolder.tv_crowdName = (TextView) convertView.findViewById(R.id.id_crowdName);
            viewHolder.tv_crowdArea = (TextView) convertView.findViewById(R.id.id_crowdArea);
            viewHolder.tv_crowdTime = (TextView) convertView.findViewById(R.id.id_crowdTime);
            viewHolder.tv_crowdTel = (TextView) convertView.findViewById(R.id.id_crowdTela);
            viewHolder.tv_crowdContext = (TextView) convertView.findViewById(R.id.id_crowdContext);
            viewHolder.tv_InputName= (TextView) convertView.findViewById(R.id.id_InputName);
            viewHolder.tv_InputTime= (TextView) convertView.findViewById(R.id.id_InputTime);
            viewHolder.tv_disposeName= (TextView) convertView.findViewById(R.id.id_disposeName);
            viewHolder.tv_disposeTime= (TextView) convertView.findViewById(R.id.id_disposeTime);
            viewHolder.tv_flag= (TextView) convertView.findViewById(R.id.id_flag);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        GrassrootsOpinion grassrootsOpinion = grassrootsOpinions.get(i);
        viewHolder.tv_crowdTime.setText(grassrootsOpinion.getCrowdTime());
        viewHolder.tv_crowdArea.setText(grassrootsOpinion.getCrowdArea());
        viewHolder.tv_crowdContext.setText(grassrootsOpinion.getCrowdContext());
        viewHolder.tv_crowdTel.setText(grassrootsOpinion.getCrowdTel());
        viewHolder.tv_disposeName.setText(grassrootsOpinion.getDisposeName());
        viewHolder.tv_disposeTime.setText(grassrootsOpinion.getDisposeTime());
        viewHolder.tv_InputName.setText(grassrootsOpinion.getInputName());
        viewHolder.tv_InputTime.setText(grassrootsOpinion.getInputTime());
        if (grassrootsOpinion.getFlag().equals("1"))
        {
            viewHolder.tv_flag.setText("已处理");
            viewHolder.tv_flag.setTextColor(MyApplication.share().getResources().getColor(R.color.green));
        }
        else
        {
            viewHolder.tv_flag.setText("未处理");
            viewHolder.tv_flag.setTextColor(MyApplication.share().getResources().getColor(R.color.red));
        }


        return convertView;
    }


    class ViewHolder {
        public TextView tv_crowdName;
        public TextView tv_crowdArea;
        public TextView tv_crowdTime;
        public TextView tv_crowdTel;
        public TextView tv_crowdContext;
        public TextView tv_InputName;
        public TextView tv_InputTime;
        public TextView tv_disposeName;
        public TextView tv_disposeTime;
        public TextView tv_flag;

    }
}
